<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Konfirmasi extends CI_Controller {

	function __construct()
	{
		parent::__construct();
		$this->load->model('Order_model');
		$this->load->library('session');
		$this->load->helper('url');
		$this->load->helper('bantuan_helper');
	}

	function index()
	{
		$this->form_validation->set_rules('order_code', 'Order Code', 'required');
		$this->form_validation->set_rules('nama', 'Nama', 'required');
		$this->form_validation->set_rules('rek_asal', 'Rekening Asal', 'required');
		$this->form_validation->set_rules('bank_asal', 'Bank Asal', 'required');
		$this->form_validation->set_rules('bank_id', 'Bank Tujuan', 'required');
		$this->form_validation->set_rules('jml_uang', 'Jumlah Uang', 'required|numeric');

		if ($this->form_validation->run() == FALSE):
			$data['title'] = 'Payment Confirmation';
			$data['ses_id'] = $this->session->userdata('session_id');
			$data['page'] = 'common';
			$data['main_view'] = 'slak/konfirmasi/index';
			$data['cumb'] = anchor('home','<strong>Home</strong>').' &raquo; Payment Confirmation';	
			$this->load->view('/slak/index',$data);
		else:

			$date = $this->input->post('tgl_byr_y').'-'.$this->input->post('tgl_byr_m').'-'.$this->input->post('tgl_byr_d');
			
			//echo $date;
	
			$data = array('order_code' => $this->input->post('order_code'),
						'nama' => $this->input->post('nama'),
						'tgl_bayar' => $date,
						'no_rek_pengirim' => $this->input->post('rek_asal'),
						'bank_pengirim' => $this->input->post('bank_asal'),
						'bank_tujuan_id' => $this->input->post('bank_id'),
						'jumlah' => $this->input->post('jml_uang'),
						//'img_url' => $this->input->post('email'),
						'status' => '1'
					);
						
			$this->Order_model->addConfirmation($data);
			$this->session->set_flashdata('message_succes_conf', '<h3>Thank you, your payment confirmation we will promptly process</h3>');
			redirect('konfirmasi','refresh');
			
		endif;
	}

}